//导入页面组件
import Login from "../Pages/Login/Login";
import Article from "../Pages/Article/Article";
import Layout from "../Pages/Layout/index";
import About from "../Pages/About/index";
import Board from "../Pages/Board/index";
import NotFound from "../Pages/NotFound/index";
//导入路由组件
// import { createHashRouter } from "react-router";
import { createBrowserRouter } from "react-router";

// 创建路由配置
// 这里有两种路由模式
// createHashRouter ---hash路由模式：/#/...
// createBrowserRouter ---history路由模式：/...
const router = createBrowserRouter([
  // 一级路由
  {
    path: "/",
    element: <Layout />,
    // 二级路由
    children: [
      {
        // 使用二级默认访问路由需index:true，不需要path:'...'
        // 默认二级路由，当访问/时，渲染组件
        index: true,
        element: <About />,
      },
      {
        path: "/board",
        element: <Board />,
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "/article/:name",
    element: <Article />,
  },
  {
    // 若没有路由则404报错
    path: "*",
    element: <NotFound />,
  },
]);

// 导出路由配置给main.tsx接收
export default router;
